# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Knut Ahlers <knut at ahlers dot me>

pkgname=dust
pkgver=0.8.6
_commit='b8aab2df979004d13c84006e378297af10e20777'
pkgrel=1
pkgdesc='A more intuitive version of du in rust'
arch=('loong64' 'x86_64')
url='https://github.com/bootandy/dust'
license=('Apache')
depends=('gcc-libs')
makedepends=('git' 'rust')
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('SKIP')

prepare() {
  cd "$pkgname"

  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

_pkgver() {
  curl -fs https://api.github.com/repos/bootandy/$pkgname/git/ref/tags/v$pkgver |
    jq -r .object.sha
}

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

  cargo build --frozen --release --all-features
}

check() {
  cd "$pkgname"

  cargo test --frozen --all-features
}

package() {
  cd "$pkgname"

  # binary
  install -vDm755 -t "$pkgdir/usr/bin" "target/release/$pkgname"

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
}

# vim:set ts=2 sw=2 et:
